//
//  PasswordViewController.m
//  Hxcsfw
//
//  Created by qiysoft on 2017/11/7.
//  Copyright © 2017年 企友软mac. All rights reserved.
//

#import "PasswordViewController.h"
#import "WWebViewController.h"
#import "JPUSHService.h"
#import "PasswordCell.h"
#define PasswordCellIndentifier @"PasswordCellIndentifier"
#import "RegisterViewController.h"

@interface PasswordViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    PasswordCell *cell1;
}

@end

@implementation PasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // 1.注册控件
    UINib *cellNib = [UINib nibWithNibName:@"PasswordCell" bundle:nil];
    [self.myTableView registerNib:cellNib forCellReuseIdentifier:PasswordCellIndentifier];
    _myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.prototypeCell  = [self.myTableView dequeueReusableCellWithIdentifier:PasswordCellIndentifier];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccessClick) name:@"LoginSuccess" object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(PASSWORDREGISTERClick) name:@"PASSWORDREGISTER" object:nil];//注册通知

}

-(void)PASSWORDREGISTERClick {//注册实现
    /*
    WWebViewController *webVc = [[WWebViewController alloc] init];
    webVc.strUrl = @"http://192.168.0.38:11000/sxhtjs/zstapp?params=%2FO5VEuP53%2BWqeopc9K5F1VM9cHFSt7skYkaNuWT%2BEhP0c0zbqoqL95WAP3ZQsCor";
    webVc.strTitle = @"注册";
    [self.navigationController pushViewController:webVc animated:YES];
     */
    
    RegisterViewController *loginVc = [[RegisterViewController alloc] init];
    [self.navigationController pushViewController:loginVc animated:YES];
}

//设置UITableViewCell的数据
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell1  = [[[NSBundle mainBundle] loadNibNamed:@"PasswordCell" owner:self options:nil] lastObject];
    cell1.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell1;
    
}

//行点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
}

//分组个数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

//列表行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
    
}

//设置行高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return WSCREENH_HEIGHT-72-49;
    
}

- (void)loginSuccessClick {
    [self.navigationController popViewControllerAnimated:NO];
}

-(void)dealloc{
    //移除所有通知监控
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)networkDidLogin:(NSDictionary *)returnDic {
    if ([WShareUtil sharedData].dicSession) {
        [JPUSHService deleteAlias:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
            WLog(@"%@",iAlias);
        } seq:10];
        NSSet *setTag = [[NSSet alloc] initWithObjects:@"register_soldier",nil];

        NSString *k = [NSString stringWithFormat:@"%@",returnDic[@"gid"]];
        if ([k isEqualToString:@"0"]) {
            setTag = [[NSSet alloc] initWithObjects:@"register_soldier",nil];
        }else if([k isEqualToString:@"2"]){
            setTag = [[NSSet alloc] initWithObjects:@"common_soldier",nil];
        }else if ([k isEqualToString:@"3"]){
            setTag = [[NSSet alloc] initWithObjects:@"silver_soldier",nil];
        }else if ([k isEqualToString:@"4"]){
            setTag = [[NSSet alloc] initWithObjects:@"gold_soldier",nil];
        }
        //    设置别名 seq 10;
        [JPUSHService deleteTags:setTag completion:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
            WLog(@"%@",iTags);
        } seq:11];
    }

    if (returnDic) {
        NSString *alias = @"cst123456";
        NSSet *setTag = [[NSSet alloc] initWithObjects:@"register_soldier",nil];

        alias = returnDic[@"userid"];
        alias = [NSString stringWithFormat:@"cst%@",alias];
        NSString *k = [NSString stringWithFormat:@"%@",returnDic[@"gid"]];
        if ([k isEqualToString:@"0"]) {
            setTag = [[NSSet alloc] initWithObjects:@"register_soldier",nil];
        }else if([k isEqualToString:@"2"]){
            setTag = [[NSSet alloc] initWithObjects:@"common_soldier",nil];
        }else if ([k isEqualToString:@"3"]){
            setTag = [[NSSet alloc] initWithObjects:@"silver_soldier",nil];
        }else if ([k isEqualToString:@"4"]){
            setTag = [[NSSet alloc] initWithObjects:@"gold_soldier",nil];
        }

        [JPUSHService setTags:setTag completion:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
            WLog(@"%@----",setTag);
        } seq:11];
        //    设置别名 seq 10;
        [JPUSHService setAlias:alias completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
            WLog(@"%@====",iAlias);
        } seq:10];
    }
}



@end
